﻿using System;
using System.Collections.Generic;

using System.Text;
using SqlCeViewer.CommonMethod;
using Microsoft.Practices.EnterpriseLibrary.Data;
using CoreEA;
using System.Data;

namespace SqlCeViewer.DbEnginer
{
    class SqlServerEnginer : IDbEnginer
    {

        public static readonly string GetColumnSchemaInfoString = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS";

        public SqlServerEnginer()
        {
            _customHandler = new CoreE(CoreE.UsedDatabaseType.SqlServer).X_Handler;
        }

        private ICoreEAHander _customHandler;
        /// <summary>
        /// My Core Handler
        /// </summary>
        ICoreEAHander IDbEnginer.CustomHandler
        {
            get { return _customHandler; }
        }

        private Database _dbHandler = null;
        Database IDbEnginer.DbHandler
        {
            get
            {
                if (_dbHandler == null)
                {
                    throw new Exception("Handle has not created,please open database first");

                }
                return _dbHandler;
            }
        }

        private List<string> _tableList = null;
        List<string> IDbEnginer.TableList
        {
            get
            {
                return _tableList;
            }
        }

        bool IDbEnginer.OpenDatabase(string dbName, string pwd, OpenModeClass curOpenMode)
        {
            throw new NotImplementedException();
        }

        Dictionary<string, DbType> IDbEnginer.GetColumnNameAndTypeFromTable(string item)
        {
            throw new NotImplementedException();
        }

        #region IDbEnginer Members

        bool IDbEnginer.CreateDataBase(string dbName, string pwd, bool Encrypt)
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.CreateDataBase(string dbName)
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.CreateDataBase(string dbName, string pwd)
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.OpenDatabase(string dbName, string pwd)
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.OpenDatabase(string dbName)
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.CreateTableWithSchemaInfo(object args, string tableName)
        {
            throw new NotImplementedException();
        }

        System.Data.DataSet IDbEnginer.GetColumnInfoFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        System.Data.DataSet IDbEnginer.GetIndexInfoFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        System.Data.DataSet IDbEnginer.GetKeyColumnInfoFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        System.Data.DataSet IDbEnginer.GetProviderInfoFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        System.Data.DataSet IDbEnginer.GetSupportedDbType()
        {
            throw new NotImplementedException();
        }

        List<string> IDbEnginer.GetColumnNameListFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        List<string> IDbEnginer.GetIndexNameListFromTable(string tableName)
        {
            throw new NotImplementedException();
        }

        List<string> IDbEnginer.GetTableList()
        {
            throw new NotImplementedException();
        }

        bool IDbEnginer.InsertData(string tableName, List<string> columnName, List<string> columnValue, List<System.Data.DbType> types)
        {
            throw new NotImplementedException();
        }

        int IDbEnginer.GetTableMaxLength
        {
            get { throw new NotImplementedException(); }
        }

        bool IDbEnginer.ExecuteSimpleCommand(string cmd)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDisposable Members

        void IDisposable.Dispose()
        {
            if (_customHandler != null)
            {
                if (_customHandler.IsOpened)
                {
                    _customHandler.Close();
                }
            }
        }

        #endregion
    }
}
